<template>
    <t-layout-page>
        <t-layout-page-item>
            <!-- <el-radio-group v-model="formOpts.labelPosition" size="small" style="margin-bottom: 15px">
          <el-radio-button label="left">左对齐</el-radio-button>
          <el-radio-button label="right">右对齐</el-radio-button>
          <el-radio-button label="top">顶部对齐</el-radio-button>
        </el-radio-group> -->
            <t-form ref="TFormDemo" v-model="formOpts.ref" :formOpts="formOpts" :widthSize="1" :label-width="200" />
        </t-layout-page-item>
    </t-layout-page>
</template>

<script setup lang="tsx">
// 获取ref
const TFormDemo: any = ref<HTMLElement | null>(null);
// 提交formOpts.ref 方式form表单
const submitForm = () => {
    formOpts.ref.validate((valid: any) => {
        console.log(88, valid);
        console.log(77, formOpts.formData);
        if (!valid) return;
        console.log("最终数据", formOpts.formData);
    });
};
// 重置form表单
const resetForm = () => {
    formOpts.formData = {};
    // 清空校验
    TFormDemo.value.clearValidate();
};
const formOpts: any = reactive({
    labelPosition: "right",
    ref: null,
    formData: {
        database: null, // 报告数据库备份周期
        CTsave: "D:\Report\CT", // CT报告保存路径
        CTbackups: "D:\Report\CT", // CT报告压缩备份路径
        MRsave: "D:\Report\MR", // MR报告保存路径
        MRbackups: "D:\Report\MR", // MR报告压缩备份路径
        DRsave: "D:\Report\DR", // DR报告保存路径
        DRbackups: "D:\Report\DR", // DR报告压缩备份路径
        CUsave: "D:\Report\CU", // 彩超报告保存路径
        CUbackups: "D:\Report\CU", // 彩超报告压缩备份路径
        logRetention: null, // 日志保留天数
        reportRecord: "365", // 报告记录保留天数
        imageFile: "365", // 影像文件保留天数
        backupFiles: "500", // 备份文件保留天数
    },
    fieldList: [
        {
            label: "报告数据库备份周期",
            value: "database",
            type: "input",
            comp: "el-input",
            placeholder: "填写CRON表达式"
        },
        { label: "CT报告保存路径", value: "CTsave", type: "input", comp: "el-input" },
        { label: "CT报告压缩备份路径", value: "CTbackups", type: "input", comp: "el-input" },
        { label: "MR报告保存路径", value: "MRsave", type: "input", comp: "el-input" },
        { label: "MR报告压缩备份路径", value: "MRbackups", type: "input", comp: "el-input" },
        { label: "DR报告保存路径", value: "DRsave", type: "input", comp: "el-input" },
        { label: "DR报告压缩备份路径", value: "DRbackups", type: "input", comp: "el-input" },
        { label: "彩超报告保存路径", value: "CUsave", type: "input", comp: "el-input" },
        { label: "彩超报告压缩备份路径", value: "CUbackups", type: "input", comp: "el-input" },
        { label: "日志保留天数", value: "logRetention", type: "input", comp: "el-input", append: "天", placeholder: "填写大于0的整数天数，如不填写则永久保留。大于天数前的日志被自动删除" },
        { label: "报告记录保留天数", value: "reportRecord", type: "input", comp: "el-input", append: "天", placeholder: "填写大于0的整数天数，如不填写则永久保留。大于天数前的报告被自动删除" },
        { label: "影像文件保留天数", value: "imageFile", type: "input", comp: "el-input", append: "天", placeholder: "填写大于0的整数天数，如不填写则永久保留。大于天数前的影像文件被自动删除" },
        { label: "备份文件保留天数", value: "backupFiles", type: "input", comp: "el-input", append: "天", placeholder: "填写大于0的整数天数，如不填写则永久保留。大于天数前的备份文件被自动删除" },
    ],
    operatorList: [
        { label: "提交", type: "danger", fun: submitForm },
        { label: "重置", type: "primary", fun: resetForm }
    ]
});
</script>